﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using park.Common;

namespace park.Equipment
{
    public partial class RepeatersList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string method = Request.Params["method"];
                if (!string.IsNullOrEmpty(method))
                {
                    switch (method)
                    {
                        case "listRepeaters":
                            {
                                PrintResult();
                                break;
                            }
                        case "DeleteRepeaters":
                            {
                                DeleteRepeaters();
                                break;
                            }
                    }

                }
            }
        }
        private void DeleteRepeaters()
        {
            string id = Request.Params["id"];

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
            bool flag = sl.DeleteRepeaters(id);

            Response.Write("{" + string.Format("\"isSuccess\":\"{0}\"", flag.ToString().ToLower()) + "}");
            Response.End();
        }
        private void PrintResult()
        {

            string cityId = Request.Params["cityId"];
            string areaId = Request.Params["areaId"];
            string streetId = Request.Params["streetId"];

            string code = Request.Params["code"];
            int page = int.Parse(Request.Params["page"]);
            int size = int.Parse(Request.Params["size"]);

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
            
            string result = sl.ListRepeaters(cityId, areaId, streetId, code, page, size);

            //string result = ""
            //    + "{"
            //    + "    \"ListRepeaters\":["
            //    + "    {"
            //    + "        \"ID\":\"001\","
            //    + "        \"No\":\"TSN4564\","
            //    + "        \"Longitude\":\"86.25\","
            //    + "        \"Latitude\":\"73.19\","
            //    + "        \"Connection\":\"18627870756\","
            //    + "        \"CollectorNo\":\"TSN4564\""
            //    + "    },"
            //    + "    {"
            //    + "        \"ID\":\"002\","
            //    + "        \"No\":\"TSN4564\","
            //    + "        \"Longitude\":\"86.25\","
            //    + "        \"Latitude\":\"73.19\","
            //    + "        \"Connection\":\"18/627870756\","
            //    + "        \"CollectorNo\":\"TSN4564\""
            //    + "    }],"
            //    + "    \"RowsCount\":\"234\""
            //    + "}";


            Response.Write(result);
            Response.End();

        }
    }
}